package com.newlink.building.common_base.utils

import android.content.Context
import com.newlink.building.common_base.compatibility.NL_Compatibility

/**
 * Created by xiaodong on 2022/8/29.
 */
class PermissionHelper private constructor(private val context: Context) {
    companion object : SingletonHolder<PermissionHelper, Context>(::PermissionHelper)

    fun hasPermission(permission: String): Boolean {

        val granted = NL_Compatibility.hasPermission(context, permission)
        if (granted) {
            logDebug<PermissionHelper>("[Permission Helper] Permission $permission is granted")
        } else {
            logWarn<PermissionHelper>("[Permission Helper] Permission $permission is denied")
        }

        return granted;
    }
}